//ScoreMapper.java
package org.example.demo3.mapper;

import org.apache.ibatis.annotations.*;
import org.example.demo3.model.Course;
import org.example.demo3.model.Score;
import org.example.demo3.model.Student;

import java.util.List;

@Mapper
public interface ScoreMapper {
    @Select("select * from score where student_id=#{student_id}")
    @Results({
            @Result(column = "course_id",property = "course",javaType = Course.class,
                    one = @One(select = "org.example.demo3.mapper.CourseMapper.selectById"))
    })
    List<Score> selectByStudentId(int student_id);

    @Select("select * from score where course_id=#{course_id}")
    @Results({
            @Result(column = "student_id",property = "student",javaType = Student.class,
                    one = @One(select = "org.example.demo3.mapper.StudentMapper.selectById"))
    })
    List<Score> selectByCourseId(@Param("course_id") int course_id);
}
